Telegram Group & Telegram Channel
🖥 Совет по Python:


from pathlib import Path

# Создаем объект Path для заданного пути к файлу
path = Path("C:/Users/test.md")

# Получаем имя файла вместе с расширением
print(path.name) # 'test.md'

# Получаем только имя файла без расширения
print(path.stem) # 'test'

# Получаем расширение файла (с точкой)
print(path.suffix) # '.md'

# Получаем родительскую директорию (папку)
print(path.parent) # 'C:/Users'

С помощью модуля pathlib вы можете получать различные части пути — имя файла, расширение, родительскую директорию. Это упрощает работу с файловыми путями и их анализ.

Объяснение:

- path.name — возвращает полное имя файла (например, test.md).

- path.stem — возвращает имя файла без расширения (например, test).

- path.suffix — возвращает расширение файла (например, .md).

- path.parent — возвращает путь к родительской директории (например, C:/Users).

Модуль pathlib позволяет удобно разбирать путь к файлу на части и работать с ними, не используя строковые операции вручную. Это особенно полезно для кроссплатформенной работы с файлами и папками.



@Python_Community_ru



tg-me.com/Python_Community_ru/2664
Create:
Last Update:

🖥 Совет по Python:


from pathlib import Path

# Создаем объект Path для заданного пути к файлу
path = Path("C:/Users/test.md")

# Получаем имя файла вместе с расширением
print(path.name) # 'test.md'

# Получаем только имя файла без расширения
print(path.stem) # 'test'

# Получаем расширение файла (с точкой)
print(path.suffix) # '.md'

# Получаем родительскую директорию (папку)
print(path.parent) # 'C:/Users'

С помощью модуля pathlib вы можете получать различные части пути — имя файла, расширение, родительскую директорию. Это упрощает работу с файловыми путями и их анализ.

Объяснение:

- path.name — возвращает полное имя файла (например, test.md).

- path.stem — возвращает имя файла без расширения (например, test).

- path.suffix — возвращает расширение файла (например, .md).

- path.parent — возвращает путь к родительской директории (например, C:/Users).

Модуль pathlib позволяет удобно разбирать путь к файлу на части и работать с ними, не используя строковые операции вручную. Это особенно полезно для кроссплатформенной работы с файлами и папками.



@Python_Community_ru

BY Python Community


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/Python_Community_ru/2664

View MORE
Open in Telegram


Python Community Telegram | DID YOU KNOW?

Date: |

The lead from Wall Street offers little clarity as the major averages opened lower on Friday and then bounced back and forth across the unchanged line, finally finishing mixed and little changed.The Dow added 33.18 points or 0.10 percent to finish at 34,798.00, while the NASDAQ eased 4.54 points or 0.03 percent to close at 15,047.70 and the S&P 500 rose 6.50 points or 0.15 percent to end at 4,455.48. For the week, the Dow rose 0.6 percent, the NASDAQ added 0.1 percent and the S&P gained 0.5 percent.The lackluster performance on Wall Street came on uncertainty about the outlook for the markets following recent volatility.

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

Python Community from de


Telegram Python Community
FROM USA